*clear
set more off

*install sutex2
*install tabout
*install balancetable
*install outreg2

*************************************************************************
*  File Name: personalnarratives_replication_251106.do                  *
*  Date:      Nov. 11, 2025                                             *
*  Author:    Nicole Audette, Jeremy Horowitz, Kristin Michelitch       *                               *
*  Purpose:   Replication Do File for Personal Narratives Reduce Nega-  *
*                tive Attidues toward Immigrant Outgroups               *
*************************************************************************

*************************************************************************
* call in data and create directories *
*************************************************************************

*use "Narratives_repdata_251106.dta" // set file path to local directory

capture mkdir "tables_figures"
capture mkdir "temp"

*************************************************************************
* Figure 3: Effects of T1 - Refugee Hardship Narrative *
*************************************************************************

*** Figure 3(A) Mean values
reg index_t1 i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m1, replace)
margins, dydx(i.trefugeevc) saving(temp/d1, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d1b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d1c, replace)

reg closeness_s i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m2, replace)
margins, dydx(i.trefugeevc) saving(temp/d2, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d2b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d2c, replace)

reg spending_toolow_s i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m3, replace)
margins, dydx(i.trefugeevc) saving(temp/d3, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d3b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d3c, replace)

reg againstwall_s i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m4, replace)
margins, dydx(i.trefugeevc) saving(temp/d4, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d4b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d4c, replace)

reg pctcitizen_s i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m5, replace)
margins, dydx(i.trefugeevc) saving(temp/d5, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d5b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d5c, replace)

reg keepdadaab_s i.trefugeevc, robust 
margins, at (trefugeevc = (0 1)) saving(temp/m6, replace)
margins, dydx(i.trefugeevc) saving(temp/d6, replace)
margins, dydx(i.trefugeevc) level(90) saving(temp/d6b, replace)
margins, dydx(i.trefugeevc) level(99) saving(temp/d6c, replace)

preserve 
 
*** predicted probabilities 
use temp/m1, clear
append using temp/m2
append using temp/m3 
append using temp/m4
append using temp/m5
append using temp/m6

egen treat=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

*** set xplacement for plot
replace xplace=.92 if order==1
replace xplace=1.08 if order==2

replace xplace=1.92 if order==3
replace xplace=2.08 if order==4

replace xplace=2.92 if order==5
replace xplace=3.08 if order==6

replace xplace=3.92 if order==7
replace xplace=4.08 if order==8

replace xplace=4.92 if order==9
replace xplace=5.08 if order==10

replace xplace=5.92 if order==11
replace xplace=6.08 if order==12
	
scatter xplace _margin if treat==0, mcolor(maroon) msymbol(Dh) || ///
rspike  _ci_lb _ci_ub xplace if treat==0, color(maroon) hor || ///
scatter xplace _margin if treat==1, mcolor(navy) msymbol(T) || ///
rspike  _ci_lb _ci_ub xplace if treat==1, color(navy) hor ///
yscale(range(.8 6.2) lcolor(gs8) reverse noextend) xscale(range(0 1) noextend) scheme(s1mono) ///
ylabel(1 "Index" 2 "Closeness" 3 "Spending too low" 4 "Oppose wall" 5 "Percent citizens" 6 "Keep Dadaab", angle(0)) ///
xtitle(" ") xlabel(0(.2)1) ytitle("") ///
legend(order(1 3) label(1 "Control") label(3 "Treatment 1")) ///
plotregion(lcolor(white)) xtitle("Mean values", margin(0 0 2 2)) ///
ysize(8) xsize(5)  scale(1.0)  name(g1_new, replace) title("(A) Mean values")
	
restore

 
*** Figure 3(B) Treatment effects
preserve

use temp/d1, clear
append using temp/d2
append using temp/d3 
append using temp/d4
append using temp/d5
append using temp/d6
append using temp/d1b
append using temp/d2b
append using temp/d3b
append using temp/d4b
append using temp/d5b
append using temp/d6b
append using temp/d1c
append using temp/d2c
append using temp/d3c
append using temp/d4c
append using temp/d5c
append using temp/d6c

gen xplace=_n
replace xplace = xplace-6 if _n>6
replace xplace = xplace-6 if _n>12
	
gen _mlab=_margin
format _mlab %9.2f

scatter xplace _margin, mcolor(black) msymbol(O) mlabel(_mlab) mlabp(12) || ///
rspike  _ci_lb _ci_ub xplace if _n<=6, color(black) hor lw(medium) || ///
rspike  _ci_lb _ci_ub xplace if _n>6 & _n<=12, color(black) hor lw(thick)   ///
yscale(range(.8 6.2) lcolor(gs8) reverse noextend) xscale(range(-.2 .3) noextend) scheme(s1mono) ///
ylabel(1 "Index" 2 "Closeness" 3 "Spending too low" 4 "Oppose wall" 5 "Percent citizens" 6 "Keep Dadaab", angle(0)) ///
xtitle(" ") xlabel(-.2(.1).3) ytitle("") ///
legend(off) ///
plotregion(lcolor(white)) xtitle("Marginal effects", margin(0 0 11 2)) ///
ysize(8) xsize(5) scale(1.0)  xline(0, lpat(shortdash)) name(g2_new, replace) title("(B) Treatment effects")

*** Combine plots and export	
graph combine g1_new g2_new, scheme(s1mono) 
graph export "tables_figures/Figure 3.pdf", replace

restore

*************************************************************************
* Figure 5: Effects of T2 - Anti-terror narrative *
*************************************************************************

reg index_t2 i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m1, replace)
margins, dydx(i.tskvc) saving(temp/d1, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d1b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d1c, replace)

reg closeness_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m2, replace)
margins, dydx(i.tskvc) saving(temp/d2, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d2b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d2c, replace)

reg peaceful_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m3, replace)
margins, dydx(i.tskvc) saving(temp/d3, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d3b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d3c, replace)

reg supportshabaab_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m4, replace)
margins, dydx(i.tskvc) saving(temp/d4, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d4b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d4c, replace)

reg nationalist_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m5, replace)
margins, dydx(i.tskvc) saving(temp/d5, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d5b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d5c, replace)

reg KSstay_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m6, replace)
margins, dydx(i.tskvc) saving(temp/d6, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d6b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d6c, replace)

reg KeepNE_s i.tskvc, robust 
margins, at (tskvc = (0 1)) saving(temp/m7, replace)
margins, dydx(i.tskvc) saving(temp/d7, replace)
margins, dydx(i.tskvc) level(90) saving(temp/d7b, replace)
margins, dydx(i.tskvc) level(99) saving(temp/d7c, replace)

preserve 
 
***Figure 5(A) Predicted values 
use temp/m1, clear
append using temp/m2
append using temp/m3 
append using temp/m4
append using temp/m5
append using temp/m6
append using temp/m7

egen treat=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

*** set xplacement for plot
replace xplace=.92 if order==1
replace xplace=1.08 if order==2

replace xplace=1.92 if order==3
replace xplace=2.08 if order==4

replace xplace=2.92 if order==5
replace xplace=3.08 if order==6

replace xplace=3.92 if order==7
replace xplace=4.08 if order==8

replace xplace=4.92 if order==9
replace xplace=5.08 if order==10

replace xplace=5.92 if order==11
replace xplace=6.08 if order==12

replace xplace=6.92 if order==13
replace xplace=7.08 if order==14
	
	
scatter xplace _margin if treat==0, mcolor(maroon) msymbol(Dh) || ///
rspike  _ci_lb _ci_ub xplace if treat==0, color(maroon) hor || ///
scatter xplace _margin if treat==1, mcolor(navy) msymbol(T) || ///
rspike  _ci_lb _ci_ub xplace if treat==1, color(navy) hor ///
yscale(range(.8 7.2) lcolor(gs8) reverse noextend) xscale(range(0 1) noextend) scheme(s1mono) ///
ylabel(1 "Index" 2 "Closeness" 3 "Peaceful" 4 "Oppose terrorism" 5 "Nationalist" 6 "Remain in Kenya" 7 "Better w/Northeastern", angle(0)) ///
xtitle(" ") xlabel(0(.2)1) ytitle("") ///
legend(order(1 3) label(1 "Control") label(3 "Treatment 2")) ///
plotregion(lcolor(white)) xtitle("Mean values", margin(0 0 2 2)) ///
ysize(8) xsize(5)  scale(1.0)  name(g1_new, replace) title("(A) Mean values")
	
restore

 
***Figure 5(B): Treatment effects

preserve 

use temp/d1, clear
append using temp/d2
append using temp/d3 
append using temp/d4
append using temp/d5
append using temp/d6
append using temp/d7
append using temp/d1b
append using temp/d2b
append using temp/d3b
append using temp/d4b
append using temp/d5b
append using temp/d6b
append using temp/d7b
append using temp/d1c
append using temp/d2c
append using temp/d3c
append using temp/d4c
append using temp/d5c
append using temp/d6c
append using temp/d7c

gen xplace=_n
replace xplace = xplace-7 if _n>7
replace xplace = xplace-7 if _n>14
	
gen _mlab=_margin
format _mlab %9.2f

scatter xplace _margin, mcolor(black) msymbol(O) mlabel(_mlab) mlabp(12) || ///
rspike  _ci_lb _ci_ub xplace if _n<=7, color(black) hor lw(medium) || ///
rspike  _ci_lb _ci_ub xplace if _n>7 & _n<=14, color(black) hor lw(thick)   ///
yscale(range(.8 7.2) lcolor(gs8) reverse noextend) xscale(range(-.2 .3) noextend) scheme(s1mono) ///
ylabel(1 "Index" 2 "Closeness" 3 "Peaceful" 4 "Oppose terrorism" 5 "Nationalist" 6 "Remain in Kenya" 7 "Better w/Northeastern", angle(0)) ///
xtitle(" ") xlabel(-.2(.1).3) ytitle("") ///
legend(off) ///
plotregion(lcolor(white)) xtitle("Marginal effects", margin(0 0 11 2)) ///
ysize(8) xsize(5) scale(1.0)  xline(0, lpat(shortdash)) name(g2_new, replace) title("(B) Treatment effects")
	
graph combine g1_new g2_new, scheme(s1mono) 
graph export "tables_figures/Figure 5.pdf", replace

restore


*************************************************************************
* Figure 6: Treatment Effects Conditional on Pre-Treatment Attitudes    *
*************************************************************************

***Left panel: T1. Refugee Hardshiop 
reg index_t1 i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg index_t1 i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg index_t1 i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg index_t1 i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8

replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f

*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.1 .2) noextend) scheme(s1mono) ///
xlabel(1 `""High security" "threat""' 2 `""High labor" "market threat""' 3 `""High cultural" "threat""' 4 `""Low" "contact""', angle(0)) ///
xtitle(" ") ylabel(-.1(.05).2, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("Marginal effects") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("(1a) Less Favorably Predisposed") name(g1, replace)

*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.1 .2) noextend) scheme(s1mono) ///
xlabel(1 `""Low security" "threat""' 2 `""Low labor" "market threat""' 3 `""Low cultural" "threat""' 4 `""High" "contact""', angle(0)) ///
xtitle(" ") ylabel(-.1(.05).2, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("Marginal effects") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("(1b) More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(5) title("T1: Refugee Hardship") scale(1.2)
graph export "tables_figures/Figure 6l.pdf", replace
restore


*** Right panel: T2. Anti-Terror
reg index_t2 i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg index_t2 i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg index_t2 i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg index_t2 i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8

replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f

*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.1 .2) noextend) scheme(s1mono) ///
xlabel(1 `""High security" "threat""' 2 `""High labor" "market threat""' 3 `""High cultural" "threat""' 4 `""Low" "contact""', angle(0)) ///
xtitle(" ") ylabel(-.1(.05).2, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("Marginal effects") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("(2a) Less Favorably Predisposed") name(g1, replace)

*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.1 .2) noextend) scheme(s1mono) ///
xlabel(1 `""Low security" "threat""' 2 `""Low labor" "market threat""' 3 `""Low cultural" "threat""' 4 `""High" "contact""', angle(0)) ///
xtitle(" ") ylabel(-.1(.05).2, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("Marginal effects") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("(2b) More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(5) title("T2: Anti-Terror") scale(1.2)
graph export "tables_figures/Figure 6r.pdf", replace

restore




*************************************************************************
* Supplemental Information
*************************************************************************

*************************************************************************
*SI Table 1 Survey Sample Comparison to Afrobarometer                   *
*************************************************************************
sum male age edu kikuyu luo kamba luhya christian muslim radio tv transport

*Afrobarometer data available online at https://afrobarometer.org/


*************************************************************************
*SI Table 2 Descriptive statistics                                      *
*************************************************************************
sum index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
dscore_pv_hi reduce_emp_hi dissimilarr_hi convoRS_hi convoSK_hi ///
male age edu wealthcashindex timenairobi kikuyu luo kamba luhya 


*************************************************************************
*SI Table 3 & 4 demographic correlates for treatments                   *
*************************************************************************
*Refugee Hardship
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' male age edu wealthcashindex timenairobi incumbent_aligned, robust // 
	capture est sto `y'
	}
	
esttab	index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/out_correlatesT1_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase 

*Citizen Antiterror
foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s {
	reg `y' male age edu wealthcashindex timenairobi incumbent_aligned, robust // 
	capture est sto `y'
	}
	
esttab	index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/out_correlatesT2_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase 

estimates clear

*************************************************************************
*SI Table 5 Balance across Treatment Conditions in Covariates           *
*************************************************************************
iebaltab male age edu wealthcashindex timenairobi kikuyu luo kamba luhya,   ///
grpvar(treatment_status) order(0 1 2) vce(robust) ///
savetex(tables_figures/balance_211207.tex) rowvarlabels replace


*************************************************************************
*SI Table 6 for Checking differential Non-response                     *
*************************************************************************
iebaltab num_missing miss_closeness miss_peaceful miss_supportshabaab miss_nationalist ///
miss_KSstay miss_KeepNE miss_spending miss_spendingNOIDK miss_againstwall miss_keepdadaab miss_pctcitizen, ///
grpvar(treatment_status) order(0 1 2) vce(robust) ///
savetex(tables_figures/nonresponse_250318.tex) rowvarlabels replace



*************************************************************************
*SI Table 7 & 8 Regression results                                      *
*************************************************************************
*Refugee Hardship
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.trefugeevc, robust // 
	capture est sto `y'
	}
	
esttab	index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/out_refmain_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase


*robust to controlling for Kamba due to slight imbalance
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.trefugeevc kamba, robust // 
	capture est sto `y'k
	}
	
	esttab index_t1k closeness_sk spending_toolow_sk againstwall_sk pctcitizen_sk keepdadaab_sk ///
	using "tables_figures/out_refmainkamba_250318.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase
	

*Citizen Anti-terror
foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s {
	reg `y' i.tskvc, robust // 
	capture est sto `y'
	}
	
esttab index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/out_ksmain_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

estimates clear


*************************************************************************
*SI Table 9 & 10 Bystanders                                             *
*************************************************************************

*Refugee Hardship
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.bystanders##i.trefugeevc, robust // 
	capture est sto `y'
	}
	
esttab index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/bystanderstrefugeevcDVs_201208coee.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

*Citizen Anti-terror
foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s {
	reg `y' i.bystanders##i.tskvc, robust // 
	capture est sto `y'
	}
	
esttab index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/bystandersskvcDVs_201208coee.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

estimates clear

*************************************************************************
*SI Table 11 & 12 Enumerator Coethnicity                                *
*************************************************************************
*Refugee Hardship
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.coethnic_enum##i.trefugeevc, robust // 
	capture est sto `y'
	}
	
esttab index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/coethnic_enumtrefugeevcDVs_211208coee.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

*Citizen Anti-terror
foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s {
	reg `y' i.coethnic_enum##i.tskvc, robust // 
	capture est sto `y'
	}
	
esttab index_t2 closeness_s closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/coethnic_enumtskvcDVs_211208coee.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

estimates clear


****************************************************************************
*SI Tables 13 & 14 Effect of Treatments on Perceived Social Desirability   *
****************************************************************************

*Refugee Hardship
foreach y in offend_somali offend_kikuyu offend_luos offend_chinese offend_wazungu offend_homosexuals {		
		reg `y' i.trefugeevc, robust 
		capture est sto `y'refvc
	}
	
esttab offend_somalirefvc  offend_kikuyurefvc  offend_luosrefvc offend_chineserefvc offend_wazungurefvc offend_homosexualsrefvc ///
		using "tables_figures/refugeevcstereo_211208ref.tex", ///
		replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		legend label nobase

foreach y in offend_muslims offend_obama offend_trump offend_nasa offend_jubilee   {				
		reg `y' i.trefugeevc, robust 
		capture est sto `y'refvc
	}
	
esttab offend_muslimsrefvc offend_obamarefvc  offend_trumprefvc  offend_nasarefvc  offend_jubileerefvc  ///
		using "tables_figures/refugeevcstereo_211208ref.tex", ///
		replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		legend label nobase
		
*Citizen Anti-terror	
foreach y in offend_somali offend_kikuyu offend_luos offend_chinese offend_wazungu offend_homosexuals {		
		reg `y' i.tskvc, robust 
		capture est sto `y'refvc
	}
	
esttab offend_somalirefvc  offend_kikuyurefvc  offend_luosrefvc offend_chineserefvc offend_wazungurefvc offend_homosexualsrefvc ///
		using "tables_figures/refugeevcstereo_200220ref.tex", ///
		replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		legend label nobase

foreach y in offend_muslims offend_obama offend_trump offend_nasa offend_jubilee   {				
		reg `y' i.tskvc, robust 
		capture est sto `y'refvc
	}
	
esttab offend_muslimsrefvc offend_obamarefvc  offend_trumprefvc  offend_nasarefvc  offend_jubileerefvc  ///
		using "tables_figures/refugeevcstereo_200220ref.tex", ///
		replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		legend label nobase
		
estimates clear


********************************************************************************
*SI Tables 15 & 16 Whether Perceived Social Desirability Moderates Treatments  *
********************************************************************************

******General social desirability bias*******		
*Refugee Hardship
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' c.offendindex##i.trefugeevc, robust // 
	capture est sto `y'
	}

esttab index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/offendindextrefugeevcDVs_200213ref.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase
	
*Citizen Anti-terror
foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s {
	reg `y' c.offendindex##i.tskvc, robust // 
	capture est sto `y'
	}
	
esttab index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/offendindextskvcDVs_200213ref.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

estimates clear


		
**************************************************************************
*SI Tables 17 & 18 Treatment Effects on outcome vars of other narrative  *
**************************************************************************

foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.tskvc, robust // 
	capture est sto `y'
	}
	
esttab index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s ///
	using "tables_figures/out_T2onT1DVs_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

	foreach y in index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s  {
	reg `y' i.trefugeevc, robust // 
	capture est sto `y'
	}
	
esttab index_t2 closeness_s peaceful_s supportshabaab_s nationalist_s KSstay_s KeepNE_s ///
	using "tables_figures/out_T2onT1DVs_211208.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase
	
estimates clear


********************************************************************************************************************
*SI Tables 19 & 20 Results Usings Alternative codings of KSstay (whether Kenyan Somalis should remain in Kenya...) *
********************************************************************************************************************

*mprobit including ``haven't heard enough to say'' as answer category
mprobit spending i.trefugeevc, robust baseoutcome(1)
capture est sto spending
esttab spending using "tables_figures/out_ref_altspend.tex", ///
replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase

* 3-category variable coding for KS stay
reg KSstay_salt i.tskvc, robust 
capture est sto KSstayalt
esttab KSstayalt using "tables_figures/out_ksstayalt.tex", ///
replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
legend label nobase

estimates clear


*************************************************************************
*SI Table 21 Regression results -- robust to controlling for Kamba
*************************************************************************

*robust to controlling for Kamba due to slight imbalance
foreach y in index_t1 closeness_s spending_toolow_s againstwall_s pctcitizen_s keepdadaab_s {
	reg `y' i.trefugeevc kamba, robust // 
	capture est sto `y'k
	}
	
esttab	index_t1k closeness_sk spending_toolow_sk againstwall_sk pctcitizen_sk keepdadaab_sk ///
using "tables_figures/out_refmainkamba_250318.tex", ///
replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
legend label nobase


*************************************************************************
* SI Table 26 Correlation matrix moderators                             *
* SI Table 27 Regression of moderators on outcomes                      *
*************************************************************************

corr dscore_pv_hi reduce_emp_hi dissimilarr_hi convoRS_hi
 

*Association between moderators and outcome indices
foreach x in dscore_somali_pv_reverse takejobs dissimilarr freqRS {
	reg index_t1 `x' , robust // 
	capture est sto `x'
	}
	
	foreach x in dscore_somali_pv_reverse takejobs dissimilarr freqSK {
	reg index_t2 `x' , robust // 
	capture est sto `x'2
	}

esttab dscore_somali_pv_reverse takejobs dissimilarr freqRS ///
dscore_somali_pv_reverse2 takejobs2 dissimilarr2 freqSK2 ///
	using "tables_figures/mod_outcomes_211222.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase
	
estimates clear
		 
		 
*************************************************************************
*SI Tables 28 & 29 Heterogeneous effects
*************************************************************************
foreach x in dscore_pv_hi reduce_emp_hi dissimilarr_hi convoRS_hi {
	reg index_t1 i.trefugeevc##i.`x', robust // 
	capture est sto `x'
	}
	
	esttab dscore_pv_hi reduce_emp_hi dissimilarr_hi convoRS_hi ///
	using "tables_figures/heterofxt1_211222.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase nobaselevels

	
foreach x in dscore_pv_hi reduce_emp_hi dissimilarr_hi convoSK_hi {
	reg index_t2 i.tskvc##i.`x', robust // 
	capture est sto `x'
	}
	
	esttab dscore_pv_hi reduce_emp_hi dissimilarr_hi convoSK_hi ///
	using "tables_figures/heterofxt2_211222.tex", ///
	replace style(tex) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	legend label nobase nobaselevels	
	
estimates clear

	 
*************************************************************************
*SI Figure 2 & 3. Heterogeneous effects with continuous moderators      *
*************************************************************************

*** Figure 2. T1 - Refugee Hardship Narrative
reg index_t1 c.dscore_somali_pv_reverse##i.trefugeevc, robust 
margins, dydx(trefugeevc) at(dscore_somali_pv_reverse=(-1.8(.3)1.8))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) ytitle("Treatment effect") ///
xlabel (-1.8 "Peaceful" -1.5 " " -1.5 " " -1.2 " " -.9 " " -.6 " " -.3 " " 0 " " .3 " " .6 " " .9 " " 1.2 " " 1.5 " " 1.8 "Violent") ylabel(, ang(0)) name(g1, replace)

reg index_t1 c.takejobs##i.trefugeevc , robust 
margins, dydx(trefugeevc) at(takejobs=(0(1)10))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) ytitle("Treatment effect") xtitle("Labor Market Threat") ///
xlabel (0 "Low" 1 " " 2 " " 3 " " 4 " " 5 " " 6 " " 7 " " 8 " " 9 " " 10 "High") ylabel(, ang(0))  name(g2, replace)

reg index_t1 c.dissimilarr##i.trefugeevc , robust 
margins, dydx(trefugeevc) at(dissimilarr=(0(1)3))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) xlabel(0 "Low" 1 " " 2 " " 3 "High") ytitle("Treatment effect") xtitle("Religious Dissimilarity") ylabel(, ang(0)) name(g3, replace)

reg index_t1 c.freqRS##i.trefugeevc , robust 
margins, dydx(trefugeevc) at(freqRS=(0(1)5))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) xlabel(0 "Low" 1 " " 2 " " 3 " " 4 " " 5 "High") ytitle("Treatment effect") xtitle("Frequency of Contact") ylabel(, ang(0)) name(g4, replace)

graph combine g1 g2 g3 g4, col(2) scheme(s1mono)  title("") xsize(6) scale(.9) imargin(10 10 10 10)
graph export "tables_figures/SI_Figure_2.pdf", replace


*** Figure 3. T2 - Somali Kenyan Narrative
reg index_t2 c.dscore_somali_pv_reverse##i.tskvc, robust 
margins, dydx(tskvc) at(dscore_somali_pv_reverse=(-1.8(.3)1.8))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) ytitle("Treatment effect") ///
xlabel (-1.8 "Peaceful" -1.5 " " -1.5 " " -1.2 " " -.9 " " -.6 " " -.3 " " 0 " " .3 " " .6 " " .9 " " 1.2 " " 1.5 " " 1.8 "Violent") ylabel(, ang(0)) name(g1, replace)

reg index_t2 c.takejobs##i.tskvc , robust 
margins, dydx(tskvc) at(takejobs=(0(1)10))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) ytitle("Treatment effect") xtitle("Labor Market Threat") ///
xlabel (0 "Low" 1 " " 2 " " 3 " " 4 " " 5 " " 6 " " 7 " " 8 " " 9 " " 10 "High") ylabel(, ang(0))  name(g2, replace)

reg index_t2 c.dissimilarr##i.tskvc , robust 
margins, dydx(tskvc) at(dissimilarr=(0(1)3))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) xlabel(0 "Low" 1 " " 2 " " 3 "High") ytitle("Treatment effect") xtitle("Religious Dissimilarity") ylabel(, ang(0)) name(g3, replace)

reg index_t2 c.freqSK##i.tskvc , robust 
margins, dydx(tskvc) at(freqSK=(0(1)5))
marginsplot, scheme(s1mono) yline(0, lc(red) lp(dash)) title("") plotregion(lc(white)) xlabel(0 "Low" 1 " " 2 " " 3 " " 4 " " 5 "High") ytitle("Treatment effect") xtitle("Frequency of Contact") ylabel(, ang(0)) name(g4, replace)

graph combine g1 g2 g3 g4, col(2) scheme(s1mono)  title("") xsize(6) scale(.9) imargin(10 10 10 10)
graph export "tables_figures/SI_Figure_3.pdf", replace



*************************************************************************
*SI Figure 4. Treatment effects on outcomes, conditional on moderators
*************************************************************************

*CLOSENESS
reg closeness_s i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg closeness_s i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg closeness_s i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg closeness_s i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Closeness") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_4a.pdf", replace

restore


*SPENDING TOO LOW
reg spending_toolow_s i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg spending_toolow_s i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg spending_toolow_s i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg spending_toolow_s i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Spending Too Low") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_4b.pdf", replace

restore


*AGAINST WALL
reg againstwall_s i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg againstwall_s i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg againstwall_s i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg againstwall_s i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Oppose Wall") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_4c.pdf", replace

restore


*PERCENT CITIZENS
reg pctcitizen_s i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg pctcitizen_s i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg pctcitizen_s i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg pctcitizen_s i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Percent Citizens") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_4d.pdf", replace

restore


*KEEP DADAAB
reg keepdadaab_s i.dscore_pv_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.trefugeevc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg keepdadaab_s i.reduce_emp_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.trefugeevc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg keepdadaab_s i.dissimilarr_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.trefugeevc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg keepdadaab_s i.convoRS_hi##i.trefugeevc, robust 
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.trefugeevc) at(convoRS_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Keep Dadaab") scale(1.7) imargin(0 0 10 10) 
graph export "tables_figures/SI_Figure_4e.pdf", replace


restore



*CLOSENESS
reg closeness_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg closeness_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg closeness_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg closeness_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)


preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Closeness") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_5a.pdf", replace

restore


*PEACEFUL
reg peaceful_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg peaceful_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg peaceful_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg peaceful_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)


preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Peaceful") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_5b.pdf", replace

restore


*Oppose terrorism
reg supportshabaab_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg supportshabaab_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg supportshabaab_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg supportshabaab_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)


preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Oppose Terrorism") scale(1.7) imargin(0 0 10 10) 
graph export "tables_figures/SI_Figure_5c.pdf", replace


restore


*NATIONALIST
reg nationalist_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg nationalist_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg nationalist_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg nationalist_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Nationalist") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_5d.pdf", replace

restore


*REMAIN
reg KSstay_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg KSstay_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg KSstay_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg KSstay_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Remain") scale(1.7) imargin(0 0 10 10) 

graph export "tables_figures/SI_Figure_5e.pdf", replace

restore

*Better off with NE
reg KeepNE_s i.dscore_pv_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) saving(temp/j1, replace)
margins, dydx(i.tskvc) at(dscore_pv_hi = (0 1)) level(90) saving(temp/j1b, replace)

reg KeepNE_s i.reduce_emp_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) saving(temp/j2, replace)
margins, dydx(i.tskvc) at(reduce_emp_hi = (0 1)) level(90) saving(temp/j2b, replace)

reg KeepNE_s i.dissimilarr_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) saving(temp/j3, replace)
margins, dydx(i.tskvc) at(dissimilarr_hi = (0 1)) level(90) saving(temp/j3b, replace)

reg KeepNE_s i.convoSK_hi##i.tskvc, robust 
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) saving(temp/j4, replace)
margins, dydx(i.tskvc) at(convoSK_hi = (0 1)) level(90) saving(temp/j4b, replace)

preserve 

use temp/j1b, clear
append using temp/j2b
append using temp/j3b 
append using temp/j4b
gen order=_n
keep order _ci_lb _ci_ub
rename _ci_lb _ci_lb90 
rename _ci_ub _ci_ub90
save temp/cis_temp.dta, replace

use temp/j1, clear
append using temp/j2
append using temp/j3 
append using temp/j4

egen mod=seq(), from(0) to(1)
gen xplace=_n
gen order=_n

merge 1:1 order using temp/cis_temp.dta

replace xplace=1 if order==1
replace xplace=1 if order==2

replace xplace=2 if order==3
replace xplace=2 if order==4

replace xplace=3 if order==5
replace xplace=3 if order==6

replace xplace=4 if order==7
replace xplace=4 if order==8


replace mod=1 if _n==7
replace mod=0 if _n==8

gen _mlab=_margin
format _mlab %9.2f


*top panel
scatter _margin xplace if mod==1, mcolor(maroon) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==1, color(maroon) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==1, color(maroon) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""High" "ST""' 2 `""High" "LMT""' 3 `""High" "CT""' 4 `""Low" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("Less Favorably Predisposed") name(g1, replace)


*bottom panel
scatter _margin xplace if mod==0, mcolor(navy) msymbol(O) mlab(_mlab) mlabp(9) ||  ///
rspike _ci_lb _ci_ub xplace if mod==0, color(navy) || ///
rspike _ci_lb90 _ci_ub90 xplace if mod==0, color(navy) lw(thick) ///
xscale(range(0.5 4.5) ) yscale(range(-.3 .3) noextend) scheme(s1mono) ///
xlabel(1 `""Low" "ST""' 2 `""Low" "LMT""' 3 `""Low" "CT""' 4 `""High" "CON""', angle(0)) ///
xtitle(" ") ylabel(-.3(.1).3, angle(0)) ///
legend(off) ///
plotregion(lcolor(white)) ytitle("") ///
xsize(4) ysize(3)  yline(0, lpat(shortdash)) scale(1.0) title("More Favorably Predisposed") name(g2, replace)

graph combine g1 g2, col(1) scheme(s1mono) xsize(3.1) ysize(8) title("Better w/NE") scale(1.7) imargin(0 0 10 10) 
graph export "tables_figures/SI_Figure_5f.pdf", replace

restore



*******************************************************************************
* SI Table 30. Associations between Moderators and Perceived Social Desirability *
*******************************************************************************

recode offend_somali (3=1) (2=2) (1=3) (0=4) (else=.), gen(offend_somali_reverse)


foreach y in dscore_pv_hi reduce_emp_hi dissimilarr_hi convoRS_hi convoSK_hi {
	ttest offend_somali_reverse, by(`y') // 
	capture est sto `y'
	}



**************************************************************************************
* SI Tables 32 - 35. Additional Moderation Tests Specified in the PAP                *
**************************************************************************************

reg index_t1 i.trefugeevc##c.hearfreqSomal, robust 
outreg2 using "tables_figures/out_ref_mods2", replace  dec(2) tex

reg index_t1 i.trefugeevc##c.dist_eastleigh, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.dscore_somali_gb, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.goodeconsoc, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.goodeconego, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##i.rural, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.wealthcashindex, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.relattend, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##i.intownwestgate, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

reg index_t1 i.trefugeevc##c.age, robust 
outreg2 using "tables_figures/out_ref_mods2", append  dec(2) tex

*second table
reg index_t1 i.trefugeevc##c.edu, robust 
outreg2 using "tables_figures/out_ref_mods2b", replace  dec(2) tex

reg index_t1 i.trefugeevc##i.male, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.kikuyu, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.luo, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.luhya, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.kamba, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##c.salienteid, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

recode occ (5=1) (.=.) (else=0), gen(unskilled_labor)
recode occ (6=1) (.=.) (else=0), gen(business)
recode occ (7=1) (.=.) (else=0), gen(unemployed)

reg index_t1 i.trefugeevc##i.unskilled_labor, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.business, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t1 i.trefugeevc##i.unemployed, robust 
outreg2 using "tables_figures/out_ref_mods2b", append  dec(2) tex

reg index_t2 i.tskvc##c.hearfreqSomal, robust 
outreg2 using "tables_figures/out_ref_mods31", replace  dec(2) tex

reg index_t2 i.tskvc##c.dist_eastleigh, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.dscore_somali_gb, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.goodeconsoc, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.goodeconego, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##i.rural, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.wealthcashindex, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.relattend, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##i.intownwestgate, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.age, robust 
outreg2 using "tables_figures/out_ref_mods31", append  dec(2) tex

reg index_t2 i.tskvc##c.edu, robust 
outreg2 using "tables_figures/out_ref_mods31b", replace  dec(2) tex

reg index_t2 i.tskvc##i.male, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.kikuyu, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.luo, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.luhya, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.kamba, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##c.salienteid, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.unskilled_labor, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.business, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex

reg index_t2 i.tskvc##i.unemployed, robust 
outreg2 using "tables_figures/out_ref_mods31b", append  dec(2) tex







	 
